/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf.views;

import com.openbrew.openbrewrf.LegacySales;
import com.openbrew.openbrewrf.POSProductServingType;
import com.openbrew.openbrewrf.POSProducts;
import com.openbrew.openbrewrf.ScanTblKeg;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "Beer")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "POSBeerVew.findAllASC", query = "SELECT b FROM POSBeerView b ORDER BY b.bName ASC"),
    @NamedQuery(name = "POSBeerVew.findAllDSC", query = "SELECT b FROM POSBeerView b ORDER BY b.bName DESC"),
    @NamedQuery(name = "POSBeerView.findProductionASC", query = "SELECT b FROM POSBeerView b WHERE b.inProduction='true' ORDER BY b.bName ASC"),
    @NamedQuery(name = "POSBeerView.findNonProductionASC", query = "SELECT b FROM POSBeerView b WHERE b.inProduction='false' ORDER BY b.bName ASC")})
public class POSBeerView implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "BId")
    private Integer bId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 40)
    @Column(name = "BName")
    private String bName;
    @Basic(optional = false)
    @NotNull
    @Column(name = "InProduction")
    private boolean inProduction;
    @OneToMany(mappedBy = "productBeer")
    private Collection<POSProducts> posProductsCollection;
    @OneToMany(mappedBy = "servingTypeBeer")
    private Collection<POSProductServingType> posProductServingTypeCollection;
    @OneToMany(mappedBy = "kegBeer")
    private Collection<ScanTblKeg> kegCollection;
    @OneToMany(mappedBy = "bBeerID")
    private Collection<BrewView> brewsCollection;
    @OneToMany(mappedBy = "beerID")
    private Collection<LegacySales> legacySalesCollection;

    public POSBeerView() {
    }

    public POSBeerView(Integer bId) {
        this.bId = bId;
    }

    public POSBeerView(Integer bId, String bName) {
        this.bId = bId;
        this.bName = bName;
    }

    public Integer getbId() {
        return bId;
    }

    public void setbId(Integer bId) {
        this.bId = bId;
    }

    public String getbName() {
        return bName;
    }

    public void setbName(String bName) {
        this.bName = bName;
    }

    public boolean getInProduction() {
        return inProduction;
    }

    public void setInProduction(boolean inProduction) {
        this.inProduction = inProduction;
    }

    @XmlTransient
    public Collection<POSProducts> getPosProductsCollection() {
        return posProductsCollection;
    }

    public void setPosProductsCollection(Collection<POSProducts> posProductsCollection) {
        this.posProductsCollection = posProductsCollection;
    }

    @XmlTransient
    public Collection<POSProductServingType> getPosProductServingTypeCollection() {
        return posProductServingTypeCollection;
    }

    public void setPosProductServingTypeCollection(Collection<POSProductServingType> posProductServingTypeCollection) {
        this.posProductServingTypeCollection = posProductServingTypeCollection;
    }

    @XmlTransient
    public Collection<ScanTblKeg> getKegCollection() {
        return kegCollection;
    }

    public void setKegCollection(Collection<ScanTblKeg> kegCollection) {
        this.kegCollection = kegCollection;
    }

    @XmlTransient
    public Collection<BrewView> getBrewsCollection() {
        return brewsCollection;
    }

    public void setBrewsCollection(Collection<BrewView> brewsCollection) {
        this.brewsCollection = brewsCollection;
    }

    @XmlTransient
    public Collection<LegacySales> getLegacySalesCollection() {
        return legacySalesCollection;
    }

    public void setLegacySalesCollection(Collection<LegacySales> legacySalesCollection) {
        this.legacySalesCollection = legacySalesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (bId != null ? bId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof POSBeerView)) {
            return false;
        }
        POSBeerView other = (POSBeerView) object;
        if ((this.bId == null && other.bId != null) || (this.bId != null && !this.bId.equals(other.bId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.POSBeerView[ bId=" + bId + " ]";
    }
}
